﻿Imports System.Data.SqlClient
Public Class frmSoCai

    Private Sub frmSoCai_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        UpdateList()
    End Sub

    Private Sub dgvList_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvList.CellDoubleClick
      
    End Sub

    Private Sub UpdateList()
        Dim strSql As String = "select ROW_NUMBER() OVER (ORDER BY sc.NgayCT) as STT, sc.LoaiCT as [Loại CT], sc.SoCT as [Số CT], sc.SoHD as [Số HĐ],"
        strSql &= " kh.TenKH as [Tên KH], sc.TongTien as [Tổng Tiền], convert(VARCHAR, NgayCT,103) as [Ngày CT], sc.MaPhieu from SoCai sc left join KhachHang kh on sc.MaKH = kh.MaKH order by STT"
        Dim myConn As New SqlConnection(modKetNoi.strConnectionString)
        Dim myTable As New DataTable
        Try
            myConn.Open()
            Dim myAdapter As New SqlDataAdapter(strSql, myConn)
            myAdapter.Fill(myTable)
            dgvList.DataSource = myTable
            dgvList.Columns.Item(0).Width = 50
            dgvList.Columns.Item(1).Width = 100
            dgvList.Columns.Item(2).Width = 100
            dgvList.Columns.Item(3).Width = 100
            dgvList.Columns.Item(4).Width = 300
            dgvList.Columns.Item(5).Width = 150
            dgvList.Columns.Item(6).Width = 150
            dgvList.Columns.Item(7).Visible = False
        Catch ex As Exception

        End Try
        myConn.Close()
        myConn.Dispose()
    End Sub

    Private Sub dgvList_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dgvList.KeyDown

    End Sub

    Private Sub DongToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DongToolStripButton.Click
        Me.Close()
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click

    End Sub

    Private Sub NewToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripButton.Click

    End Sub

    Private Sub XoaToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles XoaToolStripButton.Click

    End Sub

    Private Sub SuaToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SuaToolStripButton.Click

    End Sub
End Class